<template>
  <section>
    <table class="table table-hover">
      <thead>
        <tr>
          <th v-for="(column, index) in columns" :key="index" v-text="column.title" :style="{width: `${column.width}`}"></th>
        </tr>
      </thead>
      <tbody>
        <tr v-if="!hasData">
          <td :colspan="columns.length">
            <div class="icon-null">
              <img src="../assets/icon_null.png" alt="">
            </div>
          </td>
        </tr>
        <slot></slot>
      </tbody>
    </table>
  </section>
</template>

<script>
  export default {
    props: {
      columns: {
        type: Array,
        default() {
          return [
            {title: '企业名称', width: 'auto'},
            {title: '组织机构代码', width: 'auto'},
            {title: '法人代表', width: 'auto'},
            {title: '状态', width: 'auto'}
          ]
        }
      },
      hasData: {
        type: Boolean,
        default: true
      }
    }
  }
</script>

<style lang="scss" scoped>
  .table th {
    height: 60px;
    padding: 0;
    border-bottom: 1px dashed #DADADA;
    text-align: center;
  }
  .icon-null {
    width: 88px;
    height: 108px;
    margin: 60px auto;
  }
</style>
